home *** CD-ROM | disk | FTP | other *** search
/ Amiga Packmags / NewsFlash - Issue 03 (1989)(UGA - 17-Bit Software)[a].zip / NewsFlash - Issue 03 (1989)(UGA - 17-Bit Software)[a].adf / sources / iff.s next >
Text File  |  1988-01-19  |  9KB  |  288 lines

  1.         incdir  ":include/"
  2.  
  3.         include "exec/exec_lib.i"
  4.         include "graphics/graphics_lib.i"
  5.         include "intuition/intuition.i"
  6.         include "intuition/intuitionbase.i"
  7.         include "intuition/intuition_lib.i"
  8.  
  9.         lea     GfxName,a1
  10.         move.l  #0,d0
  11.         move.l  4,a6
  12.         jsr     _LVOOpenLibrary(a6) ;or jsr -$228(a6)
  13.         tst.l   d0
  14.         beq     stop
  15.         move.l  d0,GFXBase
  16.  
  17.         lea     IntuitionName,a1
  18.         move.l  #0,d0
  19.         move.l  4,a6
  20.         jsr     _LVOOpenLibrary(a6) ;or jsr -$228(a6)
  21.         tst.l   d0
  22.         beq     stop
  23.         move.l  d0,INTBase
  24.  
  25. IFFDisplay
  26.         lea     picture,a0      ;or move.l picture,a0 if picture is a
  27.                                 ;pointer to the memory.
  28.         cmpi.l  #'FORM',(a0)+   ;ILBM-picture must start with 'FORM'
  29.         bne     stop
  30.         move.l  (a0)+,Size      ;Number of bytes still to come
  31.         cmpi.l  #'ILBM',(a0)+   ;Is it an InterLeaved BitMap file
  32.         bne     stop
  33.         sub.l   #4,Size         ;Size = Size - 'ILBM'
  34.  
  35.         move.l  a0,ChunkPos
  36. ForEver
  37.         move.l  ChunkPos,a0     ;Start of last Chunk
  38.         add.l   ChSize,a0       ;Size of last Chunk
  39.         move.l  a0,d0
  40.         andi.l  #$0001,d0       ;If ChunkPos is odd then
  41.         beq     ok
  42.         adda.l  #1,a0           ;ChunkPos = ChunkPos + 1
  43. ok      move.l  (a0)+,D0        ;Chunk Type
  44.         move.l  (a0)+,ChSize    ;Chunk Size
  45.         move.l  a0,ChunkPos
  46.         move.l  ChSize,d1
  47.         sub.l   d1,Size
  48.         beq     stop
  49. switch                          ;Switch (d0)
  50.                                 ; (For more info about switch see a C-Book)
  51. cBMHD   cmp.l   #'BMHD',D0      ;Case 'BMHD' (Information about the picture)
  52.         bne.s   cCMAP
  53.         move.l  a0,BMHD         ;BMHD contains very important information
  54.         bra.s   ForEver         ;Next Chunk
  55.  
  56. cCMAP   cmp.l   'CMAP',D0       ;case 'CMAP' (Color Information)
  57.         bne.s   cCAMG
  58.         move.l  ChSize,D4       ;For (d4=xx;d4<0;d4--) d4 = chunk-size
  59.  
  60.         divu    #$0003,D4       ;d4 = d4 / 3    (Number of colors)
  61.         ext.l   d4
  62.         cmpi.w  #32,d4          ;if number of colors > 32 then (HalfBrite)
  63.         ble.s   kleurok
  64.         moveq.l #32,d4          ;number of colors = 32
  65. colorok move.l  d4,colorno      ;Save number of colors
  66.         subq.w  #1,D4           ;telt gemakkelijker
  67.         lea     color,A3        ;color array of word type [32]
  68.  
  69. ColorL  move.b  (a0)+,D1
  70.         lsl.w   #4,D1
  71.         or.b    (a0)+,D1
  72.         lsl.w   #4,D1
  73.         or.b    (a0)+,D1
  74.         lsr.w   #4,D1
  75.         move.w  D1,(A3)+        ;Place color in color array
  76.         dbf     D4,ColorL       ;Loop
  77.  
  78.         bra     ForEver         ;Next Chunk
  79.  
  80. cCAMG   cmp.l   #'CAMG',D0      ;case 'CAMG' (Commodore AMiGa)
  81.         bne.s   cBODY           ;           (Contains info about ViewMode)
  82.         move.l  (a0),d0
  83.         lea     MyNewScreen,a3
  84.         move.w  d0,ns_ViewModes(A3)     ;or move.w d0,$c(A3)
  85.         bra     ForEver         ;Next Chunk
  86.  
  87. cBODY   cmp.l   #'BODY',D0      ;case 'BODY'    (BitPlane info)
  88.         beq.s   BODYX
  89.                                 ;Skip all other Chunks
  90.         bra     ForEver         ;einde switch
  91.  
  92. BODYX
  93.         move.l  a0,a5           ;Save Pointer temporary in A5
  94.  
  95.         lea     MyNewScreen,a0
  96.         move.l  BMHD,a3             ;The important Information
  97.         move.w  0(a3),ns_Width(a0)  ;Width   (or move.w 0(a3),4(a0) )
  98.         move.w  2(a3),ns_Height(a0) ;Height  (or move.w 2(a3),6(a0) )
  99.         move.b  8(a3),ns_Depth+1(a0)    ;Depth (or move.w 8(a3),9(a0) )
  100.         cmpi.w  #500,(A3)       ;If width > 500 then Hires else Lores
  101.         ble.s   NoHires
  102.         ori.w   #V_HIRES,ns_ViewModes(A0)   ;Hires (or ori.w #$8000,$c(a0) )
  103. NoHires cmpi.w  #300,2(A3)  ;If Height > 300 then interlace else normal
  104.         ble.s   NoLace
  105.         ori.w   #V_LACE,ns_ViewModes(A0)    ;InterLace (ori #$4,$c(a0) )
  106.  
  107. NoLace  lea     MyNewScreen,a0
  108.         move.l  INTBase,a6
  109.         jsr     _LVOOpenScreen(a6)  ;or jsr -$c6(a6)
  110.         tst.l   d0
  111.         beq     stop
  112.         move.l  d0,MyScreen
  113.  
  114.         move.l  MyScreen,a3         ;Set Colors
  115.         lea     sc_ViewPort(a3),a0  ;or lea $2c(a3),a0
  116.         lea     color,a1
  117.         move.l  colorno,d0
  118.         move.l  GFXBase,a6
  119.         jsr     _LVOLoadRGB4(a6)    ;or jsr -$c0(a6)
  120.  
  121.         move.l  a5,a0               ;Pointer to CBODY
  122.  
  123.         move.l  MyScreen,A2
  124.         move.l  BMHD,a3
  125.         lea     192(A2),A6      ;BitMap pointer
  126.         lea     184(a2),A2      ;ViewPort Pointer
  127.         clr.l   D6
  128.         move.w  (A2),D6         ;d6 = Width in bytes
  129.         move.w  2(A3),D4        ;d4 = Height
  130.         subq.w  #1,D4           ;So it's easy to use dbra d4,label
  131.         moveq   #$00,D3
  132.  
  133. LineL   moveq   #$00,D5
  134.         move.b  8(A3),D5        ;# bitplanes
  135.         move.l  A6,A2
  136.  
  137. BitPlaneL
  138.         dbf     D5,NextBP       ;All Bitplanes used of current line?
  139.         cmpi.b  #$01,9(A3)
  140.         bne.s   zz
  141.         tst.w   D4
  142.         beq.s   zz
  143.         move.l  #$00fe0000,A1   ;????
  144.         moveq   #$00,D5
  145.         bra.s   xx
  146. zz      add.l   D6,D3
  147.         dbf     D4,LineL    ;Are all lines displayed, no LineLoop
  148.         bra.s   CheckOS     ;Goto CheckOverScan
  149.  
  150. NextBP  move.l  (A2)+,A1    ;Next Bitplane
  151.         adda.l  D3,A1
  152. xx      move.w  D6,D2
  153.         tst.b   10(A3)      ;Compression ?
  154.         bne.s   Comp        ;Yes
  155.         subq.w  #1,D2
  156. yy3     move.b  (A0)+,(A1)+
  157.         dbf     D2,yy3
  158.         bra.s   BitPlaneL
  159.  
  160. while2
  161. Comp    tst.w   D2          ;Is this line ready?
  162.         beq.s   BitPlaneL   ;Next BitplaneLine
  163.         moveq   #$00,D1     ;Clear d1
  164.         move.b  (A0)+,D1    ;Get BitPlane info
  165.         bmi.s   Crunch      ;Crunched ?
  166.  
  167.         sub.w   D1,D2       ;No, copy the next D1 bytes to the screen
  168.         subq.w  #1,D2
  169. yy1     move.b  (A0)+,(A1)+
  170.         dbf     D1,yy1
  171.         bra.s   while2
  172.  
  173. Crunch  cmp.b   #$80,D1     ;If D1 == $80 then do nothing
  174.         beq.s   while2
  175.         neg.b   D1
  176.         sub.w   D1,D2
  177.         subq.w  #1,D2
  178.         move.b  (A0)+,D0    ;Copy D0 D1 times to the screen
  179. yy2     move.b  D0,(A1)+    ;a1 = BitPlane Pointer
  180.         dbf     D1,yy2
  181.         bra.s   while2      ;Next information about the current line
  182.  
  183. CheckOS                     ;Check OverScan
  184.         move.l  BMHD,a3
  185.         cmpi.w  #352,(a3)
  186.         beq.s   OverScan
  187.         cmpi.w  #704,(a3)
  188.         bne.s   NoOverScan
  189. OverScan
  190.         move.l  INTBase,a3
  191.         move.l  868(a3),a3          ;IntuitionBase->Preferences
  192.         subi.b  #16,pf_ViewXOffset(a3)      ;or subi.b #16,$76(a3)
  193.         subi.b  #17,pf_ViewYOffset(a3)      ;or subi.b #17,$77(a3)
  194.         move.l  a3,a0
  195.         moveq.l #$e8,d0
  196.         moveq.l #1,d1
  197.         move.l  INTBase,a6
  198.         jsr     _LVOSetPrefs(a6)            ;or jsr -$144(a6)
  199. NoOverScan
  200.         move.l  MyScreen,a0
  201.         clr.l   d0
  202.         move.l  #-600,d1
  203.         move.l  INTBase,a6
  204.         jsr     _LVOMoveScreen(a6)          ;or jsr -$a2(a6)
  205.  
  206.  
  207. main    btst    #$06,$bfe001    ;Wait for left mouse button
  208.         bne.s   main
  209.  
  210.         move.l  BMHD,a3
  211.         cmpi.w  #352,(a3)
  212.         beq.s   OverScan2
  213.         cmpi.w  #704,(a3)
  214.         bne.s   NoOverScan2
  215. OverScan2                   ;Turn OverScan Off
  216.         move.l  INTBase,a3
  217.         move.l  868(a3),a3  ;IntuitionBase->Preferences
  218.         addi.b  #16,pf_ViewXOffset(a3)  ;or addi.b #16,$76(a3)
  219.           addi.b  #17,pf_ViewYOffset(a3)  ;or addi.b #17,$77(a3)
  220.         move.l  a3,a0
  221.         moveq.l #$e8,d0
  222.         moveq.l #1,d1
  223.         move.l  INTBase,a6
  224.         jsr     _LVOSetPrefs(a6)        ;or jsr -$144(a6)
  225. NoOverScan2
  226.  
  227. stop
  228.         move.l  MyScreen,a0
  229.         cmpa.l  #0,a0
  230.         beq.s   CloseGFX
  231.         move.l  INTBase,a6          ;Close Screen
  232.         jsr     _LVOCloseScreen(a6) ;or jsr -$42(a6)
  233.  
  234. CloseGFX            ;Close Graphics.library
  235.         move.l  GFXBase,a1
  236.         cmpa.l  #0,a1
  237.         beq.s   CloseINT
  238.         move.l  4,a6
  239.         jsr     _LVOCloseLibrary(a6)    ;or jsr -$19e(a6)
  240.  
  241. CloseINT            ;Close Intuition.library
  242.         move.l  INTBase,a1
  243.         cmpa.l  #0,a1
  244.         beq.s   End
  245.         move.l  4,a6
  246.         jsr     _LVOCloseLibrary(a6)    ;or jsr -$19e(a6)
  247. End
  248.  
  249.         clr.l   d0      ;Clear Return Value
  250.         rts
  251.  
  252. GfxName dc.b    'graphics.library',0
  253. IntuitionName
  254.         dc.b    'intuition.library',0
  255.         even
  256. color   dcb.w   32
  257. colorno dc.l    0
  258.  
  259. MyNewScreen
  260.         dc.w    0,600       ;left, top
  261.         dc.w    320,256     ;width, height
  262.         dc.w    2           ;Depth
  263.         dc.b    0,1         ;pens
  264.         dc.w    0           ;ViewModes (is standing in CAMG)
  265.         dc.w    CUSTOMSCREEN    ;type (or dc.w $f)
  266.         dc.l    0           ;font
  267.         dc.l    0           ;title
  268.         dc.l    0           ;gadgets
  269.         dc.l    0           ;BitMap
  270.  
  271. GFXBase dc.l    0           ;struct GfxBase *GfxBase
  272. INTBase
  273.         dc.l    0           ;struct IntuitionBase *IntuitionBase
  274. MyScreen
  275.         dc.l    0           ;Struct Screen *Screen
  276. BMHD    dc.l    0
  277. ChSize  dc.l    0
  278. Size    dc.l    0
  279. ChunkPos
  280.         dc.l    0
  281.  
  282.         section "Picture",data
  283. picture dc.b    Size_Of_Iff-File
  284.                 ;Use includebin (or something like that) in DevPac to load
  285.                 ;the Iff_file
  286.                 ;Seka users must use RI to load the file
  287.  
  288.